package com.bing.bingPro.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bing.bingPro.controller.dto.TFiveOrderTypeDto;
import com.bing.bingPro.controller.vo.TInstallOrderVo;
import com.bing.bingPro.entity.TInstallOrder;
import com.bing.bingPro.mapper.TInstallOrderMapper;
import com.bing.bingPro.service.TInstallOrderService;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author qilong
 * @description 针对表【t_install_order】的数据库操作Service实现
 * @createDate
 */
@Service
public class TInstallOrderServiceImpl extends ServiceImpl<TInstallOrderMapper, TInstallOrder>
        implements TInstallOrderService {

    @Override
    public List<TInstallOrderVo> installList(TFiveOrderTypeDto tOrderYearDto) {
        Date date = Date.valueOf(tOrderYearDto.getTime());
        return baseMapper.selectList(Wrappers.lambdaQuery(TInstallOrder.class)
                        .eq(true, TInstallOrder::getDt, date))
                .stream()
                .map(tInstallOrder -> {
                    TInstallOrderVo vo = new TInstallOrderVo();
                    BeanUtil.copyProperties(tInstallOrder, vo);
                    return vo;
                })
                .collect(Collectors.toList());
        //return baseMapper.selectInstallList(tOrderYearDto);
    }

    @Override
    public List<TInstallOrderVo> exportInstall(TFiveOrderTypeDto tOrderYearDto) {
        List<TInstallOrderVo> tInstallOrderVos = this.installList(tOrderYearDto);
        return tInstallOrderVos.stream()
                .map(tInstallOrder -> {
                    TInstallOrderVo vo = new TInstallOrderVo();
                    BeanUtil.copyProperties(tInstallOrder, vo);
                    return vo;
                })
                .collect(Collectors.toList());
    }
}




